package com.example.user.common;

public class ResultUtil {

    /**
     * 成功
     * @param data
     * @return
     * @param <T>
     */
    public static <T> BaseResponse<T> success(T data) {
        return new BaseResponse<>(0 , data , "ok");
    }

    /**
     * 失败
     * @param erroCode
     * @return
     */
    public static BaseResponse error(ErrorCode erroCode) {
        return new BaseResponse<>(erroCode);
    }


    /**
     *
     * @param erroCode
     * @param message
     * @param description
     * @return
     */
    public static BaseResponse error(ErrorCode erroCode , String message , String description) {
        return new BaseResponse(erroCode.getCode(), null , message, description);
    }

    public static BaseResponse error(int code , String message , String description) {
        return new BaseResponse(code, null , message, description);
    }
}
